#include <stdio.h>
#include "Vector.h"

void doVecPointers(Vector4f* a, Vector4f* b, Vector4f* result) {
	result->x = a->x * b->x;
	result->y = a->x * b->x + b->x * b->y;
}

void doVecPointersRestrict(Vector4f* __restrict a, Vector4f* __restrict b, Vector4f* __restrict result) {
	result->x = a->x * b->x;
	result->y = a->x * b->x + a->y * b->y;
}

void doVecPointersLocal(Vector4f* a, Vector4f* b, Vector4f* result) {
	result->x = a->x * b->x;
	result->y = result->x + b->x * b->y;
}

void doVecRefs(Vector4f& a, Vector4f& b, Vector4f& result) {
	result.x = a.x * b.x;
	result.y = a.x * b.x + a.y * b.y;
}

void doVecRefsRestrict(Vector4f& __restrict a, Vector4f& __restrict b, Vector4f& __restrict result) {
	result.x = a.x * b.x;
	result.y = a.x * b.x + a.y * b.y;
}

int main(int argc, char** argv) {
	
	Vector4f a,b,c;
	a.x = 2.0f;
	a.y = 2.0f;
	b.x = 1.0f;
	b.y = 3.0f;
	c.x = 0.0f;
	c.y = 0.0f;


	printf("Input:\t\t\t a=(%g,%g) b=(%g,%g) c=(%g,%g))\n", a.x, a.y, b.x, b.y, c.x, c.y);
	doVecPointers(&a,&b,&a);
	printf("Pointers:\t\t a=(%g,%g) b=(%g,%g) c=(%g,%g))\n", a.x, a.y, b.x, b.y, c.x, c.y);
	a.x = 2.0f;
	a.y = 2.0f;
	doVecPointersRestrict(&a,&b,&a);
	printf("Pointers restrict:\t a=(%g,%g) b=(%g,%g) c=(%g,%g))\n", a.x, a.y, b.x, b.y, c.x, c.y);
	a.x = 2.0f;
	a.y = 2.0f;
	doVecRefs(a,b,a);
	printf("Refs:\t\t\t a=(%g,%g) b=(%g,%g) c=(%g,%g))\n", a.x, a.y, b.x, b.y, c.x, c.y);
	a.x = 2.0f;
	a.y = 2.0f;
	doVecRefsRestrict(a,b,a);
	printf("Refs restrict:\t\t a=(%g,%g) b=(%g,%g) c=(%g,%g))\n", a.x, a.y, b.x, b.y, c.x, c.y);

	return 0;
}